import Api from "@/src/tools/request.js";

import addressApiMappers from "./backend/api/address.js";
import orderApiMapppers from "./backend/api/order.js";
import articleApiMappers from "./backend/api/article.js";
import payApiMappers from "./backend/api/pay.js";
import memberApiMappers from "./backend/api/member.js";
import publicApiMappers from "./backend/api/public.js";
import favouriteApiMappers from "./backend/api/favourite.js";
import cartApiMappers from "./backend/api/cart.js";
import chatApiMappers from "./backend/api/chat.js";
import messageApiMappers from "./backend/api/message.js";
import uploadApiMappers from "./backend/api/upload.js";

// export default ApiMap;
/**
 * @exports 
 * @type {Record<string, (params: any) => Promise<any>>}
 */
export default [
  ...messageApiMappers,
  ...addressApiMappers,
  ...orderApiMapppers,
  ...articleApiMappers,
  ...payApiMappers,
  ...memberApiMappers,
  ...publicApiMappers,
  ...favouriteApiMappers,
  ...cartApiMappers,
  ...chatApiMappers,
  ...uploadApiMappers,
].reduce((pre, [name, url, type]) => {
  pre[name] = (params) => Api[`_${type || "post"}`](url, params);
  return pre;
}, {});
